package cn.lyl.canting.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import cn.lyl.canting.R;

//订单详情
public class OrderContentActivity extends AppCompatActivity {

    private Toolbar content_toolbar;
    private ImageView content_goods_img;
    private TextView content_foodName;
    private TextView content_foodContent;
    private TextView content_allPrice;
    private Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_content);
        initView();
        updateUi();
    }

    private void initView() {
        content_toolbar = (Toolbar) findViewById(R.id.content_toolbar);
        content_goods_img = (ImageView) findViewById(R.id.content_goods_img);
        content_foodName = (TextView) findViewById(R.id.content_foodName);
        content_foodContent = (TextView) findViewById(R.id.content_foodContent);
        content_allPrice = (TextView) findViewById(R.id.content_allPrice);
        intent = getIntent();

        //toolbar
        setSupportActionBar(content_toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);

        content_toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    //更新界面
    public void updateUi() {
        content_foodName.setText(intent.getStringExtra("name"));
        content_foodContent.setText(intent.getStringExtra("content"));
        content_allPrice.setText("共消费:"+intent.getIntExtra("price",0));
        content_goods_img.setImageResource(intent.getIntExtra("img",0));
    }
}
